package taller2.controller.listeners.evaluateMeButtons;

import java.awt.event.ActionEvent;
import java.util.Random;

import taller2.interfaces.AlgorithmApplicator;
import taller2.interfaces.Graph;
import taller2.model.factorys.GraphFactory;
import taller2.model.graph.algorithms.PrimApplicator;
import taller2.view.windows.supervisor.PrimmSupervisorWindow;

public class PrimmEvaluateMeButtonListener extends EvaluateMeButtonListener{

	public PrimmEvaluateMeButtonListener(AlgorithmApplicator aplicator) {
		super(aplicator);
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		menu.unselectButtons();
		
		PrimApplicator p = (PrimApplicator)aplicator;
		
		Random rnd = new Random();
		int pos = rnd.nextInt(p.getGraphCount());

		
		String path = p.getGraphPath(pos);
		Graph g = GraphFactory.undirectedGraphInstance();
		
		g.load(path);
			
		if(!g.getNodes().isEmpty())
			new PrimmSupervisorWindow(g);
	}

}
